#include <stdio.h>
#include <stdlib.h>

typedef struct body
{
	float x, y, z;
	float vx, vy, vz;
	float mass;
} body;

typedef struct bodyList
{
	body* bodies;
	int size;
} bodyList;

bodyList* readBodyList()
{
	// read in number of bodies
	int num_bodies;
	scanf("%d\n", &num_bodies);

	// allocate body list
	bodyList* bl = (bodyList*)malloc(sizeof(bodyList));
	bl->bodies = (body*)malloc(num_bodies*sizeof(body));
	bl->size = num_bodies;

	// read in bodies
	int i;
	for (i = 0; i != num_bodies; ++i)
	{
		body* b = &bl->bodies[i];
		scanf("%f %f %f %f %f %f %f\n", &b->x, &b->y, &b->z,
			&b->vx, &b->vy, &b->vz, &b->mass);
	}

	return bl;
}

void freeBodyList(bodyList* bl)
{
	free(bl->bodies);
	free(bl);
}
